package sskj.regulatory.presentation.screen.forgetpas

import isskj.regulatory.presentation.base_mvp.api.ApiPresenter
import sskj.regulatory.data.response.Response
import sskj.regulatory.domain.entity.user.UserEntity
import sskj.regulatory.domain.fetcher.result_listener.RequestType
import javax.inject.Inject

class ForgetPasResetPasPresenter @Inject constructor()
    : ApiPresenter<ForgetPasResetPasContract.View>(), ForgetPasResetPasContract.Presenter {


    override fun reSetPas(userEntity: UserEntity) {
        view.showLoading()
        fetch(userInteractor.updatePassword(userEntity), RequestType.UPDATE_PASSWORD) { it: Response ->
            view.hideLoading()
            when (it.success) {
                true -> view.resetpasOk()
                false -> view.resetpasError(it.msg)
            }
        }
    }

    override fun onRequestError(errorCode: String?, errorMessage: String?) {
        view.hideLoading()
        view.resetpasError(errorMessage)
    }
}